<template>
  <el-container class="home-container">
    <el-header>
      <div class="left">
        <img src="../assets/hana.png" alt="" />
        <span>花花电商管理系统</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <l-aside :menulist="menulist" />
      <el-main>
        <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
const Aside = () => import('@/components/Aside')
export default {
  data() {
    return {
      menulist: []
    }
  },
  components: {
    'l-aside': Aside
  },
  created() {
    this.getMenuList()
  },

  methods: {
    logout() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },

    async getMenuList() {
      const { data: res } = await this.$http.get('menus')
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error('res.meta.msg')
      this.menulist = res.data
    }
  }
}
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #373d41;
  padding-left: 5px;
  .left {
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 20px;
    img {
      height: 90px;
      // padding: ;
    }
  }
}

.el-main {
  background-color: #eaedf1;
}
</style>
